NOTE: There has been an initialization problem. Reinitializing variables…